﻿using System;

namespace WiMo.Games.Silverlight.GameEngine
{
    public class AssetFactory : IAssetFactory
    {
        IGameEngine _engine;

        public AssetFactory(IGameEngine engine)
        {
            _engine = engine;
        }

        public WiMo.Games.Audio.IGameAudio CreateAudioInstance()
        {
            //TODO: Need to think through the design around AudioInstance
            return null;
        }

        public WiMo.Games.Drawables.ISpriteImage CreateSpriteImage()
        {
            var image = _engine.Display.CreateSpriteImage();
            image.Scale = _engine.Display.ScaleFactor;
            image.PhysicsManager = _engine.PhysicsManager;
            image.CollisionManager = _engine.CollisionManager;

            return image;            
        }

        public WiMo.Games.Drawables.ISpriteText CreateText()
        {
            var text = _engine.Display.CreateText();
            text.PhysicsManager = _engine.PhysicsManager;
            text.CollisionManager = _engine.CollisionManager;
            text.Scale = _engine.Display.ScaleFactor;
            return text;
        }

        public WiMo.Games.Drawables.ISpriteShape CreateRectangle()
        {
            var rect = _engine.Display.CreateRectangle();
            rect.PhysicsManager = _engine.PhysicsManager;
            rect.CollisionManager = _engine.CollisionManager;
            rect.Scale = _engine.Display.ScaleFactor;
            return rect;
        }

        public WiMo.Games.Drawables.ISpriteShape CreatePolygon()
        {
            var poly = _engine.Display.CreatePolygon();
            poly.PhysicsManager = _engine.PhysicsManager;
            poly.CollisionManager = _engine.CollisionManager;
            poly.Scale = _engine.Display.ScaleFactor;
            return poly;
        }

        public WiMo.Games.Drawables.ISpriteShape CreateLineList()
        {
            var lineList = _engine.Display.CreateLineList();
            lineList.PhysicsManager = _engine.PhysicsManager;
            lineList.CollisionManager = _engine.CollisionManager;
            lineList.Scale = _engine.Display.ScaleFactor;
            return lineList;
        }

        public WiMo.Games.Drawables.ISpriteShape CreateCircle()
        {
            var circle = _engine.Display.CreateEllipse();
            circle.Scale = _engine.Display.ScaleFactor;
            circle.PhysicsManager = _engine.PhysicsManager;
            circle.CollisionManager = _engine.CollisionManager;
            return circle;
        }

        public WiMo.Games.Drawables.ISpriteShape CreateEllipse()
        {
            var circle = _engine.Display.CreateEllipse();
            circle.Scale = _engine.Display.ScaleFactor;
            circle.PhysicsManager = _engine.PhysicsManager;
            circle.CollisionManager = _engine.CollisionManager;
            return circle;
        }

        public ISpriteFont CreateFont()
        {
            return new SpriteFont();
        }

        public IContentManager CreateContentManager(IGameEngine engine)
        {
            return new ContentManager(engine);
        }
    }
}
